﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SharpRedisDesktopManager.Core.Models;
using SharpRedisDesktopManager.Core.ViewModels;
using hc = HandyControl.Controls;

namespace SharpRedisDesktopManager.UserControls
{
    /// <summary>
    /// ConnectionInfoItemControl.xaml 的交互逻辑
    /// </summary>
    public partial class ConnectionInfoItemControl : UserControl
    {
        public RedisConnectionInfo ConnectionInfo { get; set; }

        public ConnectionInfoItemControl()
        {
            InitializeComponent();
        }

        public ConnectionInfoItemControl(RedisConnectionInfo redisConnectionInfo)
        {
            InitializeComponent();
            ConnectionInfo = redisConnectionInfo;
            this.DataContext = ConnectionInfo;
        }

        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            hc.MessageBox.Show(App.Current.MainWindow, "确认要删除此连接吗?", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning);
        }
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            hc.MessageBox.Show("编辑");
        }

        private void BtnFresh_Click(object sender, RoutedEventArgs e)
        {
            hc.MessageBox.Show("刷新");
        }

        /// <summary>
        /// 为了自适应
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OutSide_SizeChanged(object sender, SizeChangedEventArgs e)
        {

        }


        private void txtName_Loaded(object sender, RoutedEventArgs e)
        {
            // 当控价Load完成之后，会收到传递进来的DataContext
            if(this.DataContext != null)
            {
                this.ConnectionInfo = this.DataContext as RedisConnectionInfo;
            }
        }
    }
}
